from flask import Flask, redirect, url_for, render_template, request, flash

app = Flask(__name__)
app.secret_key = "random string"

@app.route('/')
def index():
    return render_template('index2.html')

@app.route('/login', methods = ['GET', 'POST'])
def login():
    error = None
    if request.method == 'POST':
        if request.form['username'] != 'admin' or request.form['password'] != 'admin':
            print(request.method)
            error = 'Invalid username or password. Please try again.'
        else:
            flash('You were successfully logged in')
            flash('log out before you login again')
        return redirect(url_for('index'))
    else:
        print(request.method)
        flash("Method not post")
    return render_template('log_in.html', error = error)

if __name__ == '__main__':
    app.run(debug=True)